package com.tinyblog.ajax2;
import org.jdom.*;
import java.util.*;

public class BlogList {
	private String listid = "";
	private String listname = "";
	private int itemtotal = 0;
	private Map listitem = new HashMap();
	
	public BlogList() {
		
	}
	public BlogList(Element element) {
		this.setListid(element.getAttributeValue("listid"));
		this.setListname(element.getAttributeValue("listname"));
		this.setItemtotal(Integer.parseInt(element.getChildText("itemtotal")));
	}
	public void initialItem(Element element) {
		this.setListid(element.getAttributeValue("listid"));
		this.setListname(element.getAttributeValue("listname"));
		this.setItemtotal(Integer.parseInt(element.getChildText("itemtotal")));
		if(element.getChildren("item").size()!=0) {
			Iterator iterator = element.getChildren("item").iterator();
			do{
				Element element1 = (Element)iterator.next();
				BlogListItem item = new BlogListItem(element1);
				this.listitem.put(item.getItemid(),item);
			}while(iterator.hasNext());
		}
	}
	public String getListid() {
		return this.listid;
	}
	public void setListid(String listid) {
		this.listid = listid;
	}
	public String getListname() {
		return this.listname;
	}
	public void setListname(String listname) {
		this.listname = listname;
	}
	public int getItemtotal() {
		return this.itemtotal;
	}
	public void setItemtotal(int itemtotal) {
		this.itemtotal = itemtotal;
	}
	public Map getListitem() {
		return this.listitem;
	}
	public void addItem(BlogListItem item) {
		this.listitem.put(item.getItemid(),item);
	}
}
